package com.smart.jetpackcomposestate.examples

import android.os.Bundle
import android.text.Editable
import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.doAfterTextChanged
import com.smart.jetpackcomposestate.R
import com.smart.jetpackcomposestate.databinding.ActivityHelloComposeStateBinding

/**
 * @author huangzehui
 * @date 6/8/2025 上午12:06 周三
 * @description
 */
class HelloComposeStateActivity : AppCompatActivity() {

    private val binding by lazy {
        ActivityHelloComposeStateBinding.inflate(layoutInflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        setTheme(R.style.Theme_DN_Compose_Learn1)
        super.onCreate(savedInstanceState)
        setContentView(binding.root)

        binding.etText.doAfterTextChanged { text: Editable? ->
            updateHello(text?.toString() ?: "")
        }
    }

    private fun updateHello(name: String) {
        binding.tvText.text = name
    }

}